package com.cf.wmsg.model;

import com.cf.crud.mapper.BaseMapper;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

@Mapper
public interface WebMessageDao extends BaseMapper<WebMessage> {
    @Select("select * from webMessage where userId=#{userId}")
    Page<WebMessage> selectByUser(@Param("userId") long userId);

    @Update("update webMessage set watched=true where id=#{id} and userId=#{userId}")
    int watch(@Param("id") long messageId, @Param("userId") long userId);

    @Select("select * from webMessage where type=#{type} and bizData=#{bizData}")
    WebMessage selectByTypeAndBzData(@Param("type") String type, @Param("bizData") String bizId);

    @Delete("delete from webMessage where id=#{messageId} and userId=#{userId}")
    int deleteByPrimaryKeyAndUserId(@Param("messageId") long messageId, @Param("userId") long userId);
}
